<?php

/**
 * @see Zend_View_Helper_HtmlElement
 */
require_once 'Zend/View/Helper/HtmlElement.php';

/**
 * @see Zend_Json
 */
require_once 'Zend/Json.php';

/**
 * Gera o HTML da tabela do flexgrid.
 *
 * @category Tavs
 * @package Tavs_View_Helper
 * @subpackage Flexigrid
 *
 * @author Tales Santos <tales.augusto.santos>
 */
class Tavs_View_Helper_Flexigrid extends Zend_View_Helper_HtmlElement
{
	/**
	 * Gera o XHTML para formacao do grid.
	 *
	 * @author Tales Augusto <tales.augusto.santos@gmail.com>
	 *
	 * @param string $selector
	 * @param array $options
	 * @param array $tableAttribs
	 *
	 * @return string $table
	 */
	public function flexigrid($selector, array $options, array $tableAttribs)
	{
		$onready_content = '$("'. $selector .'").flexigrid(' . Zend_Json::encode($options) . ')';

		$objJQuery = $this->view->JQuery();
		$objJQuery
			->enable()
			->addOnLoad($onready_content);

		$table = '<table' . $this->_htmlAttribs($tableAttribs)  . '>' . PHP_EOL;
		$table .= '<tr><td class="hidden"><!--&nbsp;--></td></tr>' . PHP_EOL;
		$table .= '</table>' . PHP_EOL;

		return $table;
	}
}